<?php

class Page_Controller_Browse_Profile extends Nuo_Controller
{

	function getMap()
	{
		return array(
			'feed' => 'activity/element/browse/profile/feed',
			'blog' => 'blog/element/browse/profile/index',
			'video' => 'video/element/browse/profile/index',
			'page' => 'page/element/browse/profile/index',
			'poll' => 'poll/element/browse/profile/index',
			'event' => 'event/element/browse/profile/index',
			'photo' => 'photo/element/browse/profile/photo',
			'timeline' => 'activity/element/browse/timeline',
			'welcome' => 'user/element/browse/profile/welcome',
			'request' => 'activity/element/browse/profile/request',
			'friend' => 'friend/element/browse/profile/friend',
			'message/inbox' => 'message/element/browse/profile/inbox',
			'message/sent' => 'message/element/browse/profile/sent',
			'notification' => 'activity/element/browse/profile/notification',
		);
	}

	function execute($request)
	{
		$pageId = $request -> getParam('page_id');

		$page = Nuo::getTable('page') -> find($pageId) -> current();

		Nuo::setVar('mainResource', $page);

		$tab = $request -> getParam('tab');

		if (!$tab)
		{
			$tab = 'feed';
		}

		$maps = $this -> getMap();

		$element = isset($maps[$tab]) ? $maps[$tab] : $maps['feed'];

		return  Nuo::renderWidget($element, $request -> getParams());
	}

}
